﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UFramework.Tools
{
    public class Fps : MonoBehaviour
    {
        private float nextTime = 0; //下次生成的时间
        public float interva = 1;//间隔时间
        private int frame = 0;//帧数

        private int fps;//帧率
        private void Update()
        {
            frame++;
            if (Time.time > nextTime)
            {
                fps = (int)((float)frame / interva);
                frame = 0;
                nextTime += interva;
            }
        }

        private void OnGUI()
        {
            GUILayout.Label("Fps:" + fps);
        }
    }
}